<template>
  <svg class="vue-svg-icon" :class="svgClass" aria-hidden="true">
    <use :xlink:href="iconName"></use>
  </svg>
</template>

<script>
  export default {
    name: 'svg-icon',
    props: {
      //icon图标名
      iconClass: {
        type: String,
        default: 'down',
        required: true,
      },
      //样式类名
      className: {
        type: String,
      },
    },
    computed: {
      iconName() {
        return '#' + this.iconClass;
      },
      svgClass() {
        return this.className || 'vue-icon-hover';
      },
    },
  };
</script>

<style scoped>
  .vue-svg-icon {
    width: 1em;
    height: 1em;
  }
  .vue-icon-hover {
    vertical-align: -0.1em;
    fill: currentColor;
    overflow: hidden;
  }
</style>
